package com.example.demo02.service;

import com.example.demo02.dao.TeacherRepository;
import com.example.demo02.entity.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName TeacherServiceImpl
 * @Description TODO
 * @Author tianqinglong
 * @Date 10:38 2022/7/27
 * @Version 1.0
 **/
@Service
public class TeacherServiceImpl implements TeacherService{
    @Autowired
    private TeacherRepository repository;

    @Override
    public void deleteTeacher(Integer id) {
        repository.deleteById(Long.valueOf(id));
    }

    @Override
    public Teacher updateTeacher(Teacher teacher) {
        return repository.save(teacher);
    }

    @Override
    public List<Teacher> findAllTeacher() {
        return repository.findAll();
    }

    @Override
    public Teacher findTeacherById(Long id) {
        return repository.getById(id);
    }


}
